package com.sure0000.basic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author xuyouchang@supcon.com
 * @date 2020/3/12.
 */
public class Regex {
    public static void main(String[] args) {
        String line = "-yqu queas12ue   -ys 4 -ytm 1024MB -yjm 1024MB -yn 5 -yj test.jar";
        List<String> params = new ArrayList<>();
        params.add("-yqu");
        params.add("-ys");
        params.add("-ytm");
        params.add("-yjm");
        params.add("-yn");
        params.add("-yj");

        Map<String, Object> map = new HashMap<>();
        params.forEach((param) -> {
            String pattern = "(" + param + ")" + "(\\s)(\\S*)(\\s)*";
            Pattern r = Pattern.compile(pattern);
            Matcher m = r.matcher(line);

            if (m.find( )) {
                map.put(param, m.group(3));
                System.out.println("Found value: " + m.group(3) );
            } else {
                System.out.println(param + "NO MATCH");
            }
        });
    }
}
